package com.clstu.homework;

import org.testng.annotations.Test;

import java.io.*;
import java.util.Properties;

public class Homework03 {
    public static void main(String[] args) throws IOException {
        Properties properties = new Properties();
        properties.load(new FileReader("src\\dog.properties"));
        String name = properties.getProperty("name");
        Integer age = new Integer(properties.getProperty("age"));
        String color = properties.getProperty("color");
        Dog dog = new Dog(name,age,color);
        System.out.println("dog 创建成功 信息====="+dog);
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("D:\\dog.dat"));
        objectOutputStream.writeObject(dog);
        objectOutputStream.close();//关闭文件
        System.out.println("文件写入成功--------");
    }

    @Test
    public void m1() throws IOException, ClassNotFoundException {
        ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("D:\\dog.dat"));
        Dog dog = (Dog)objectInputStream.readObject();
        System.out.println("========读到的狗狗信息=======");
        System.out.println(dog);
    }
}
